<html>
 <head>
  <title>Test Page for Factories</title>
  <script language="javascript" src="../../jsunit/app/jsUnitCore.js"></script>
  <script language="javascript" src="../compiled/ca-all.js"></script>
 </head>
 <body>
  <script language="javascript">
    function testCreation() {
	    //Implements IAnotherConsole
	    function aTestClass(msg){}
	    aTestClass.prototype.Test1 = function(){};
		function aTest(){
			return new aTestClass();
		}
	    var success = false;
		try{
			CA.Factories.Register("ITest1",aTest);
		}catch(e){
			success = true;
		}
		assertTrue("Should fail due to undefined interface",success);
	    CA.Interfaces.Create("ITest1", ["Test1"]);
		CA.Factories.Register("ITest1",aTest);
		var o = CA.Factories.Create("ITest1");
		assertNotNull("Factor should return an object",o);
		assertTrue("Is an instance of aTestClass",(o instanceof aTestClass));
	    var success = false;
		try{
			CA.Factories.Register("ITest1",aTest);
		}catch(e){
			success = true;
		}
		assertTrue("Should fail due to factory existing",success);		
    }
  </script>
 </body>
</html>